home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / lang / fpcsrc.lha / fpc / compiler / globals.pas < prev    next >
Pascal/Delphi Source File  |  1998-09-24  |  37KB  |  1,307 lines

  1. {
  2.     $Id: globals.pas,v 1.6.2.7 1998/08/18 13:41:22 carl Exp $
  3.     Copyright (C) 1993-98 by Florian Klaempfl
  4.  
  5.     This unit implements some support functions and global variables
  6.  
  7.     This program is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  ****************************************************************************
  22. }
  23.  
  24. {$ifdef tp}
  25.   {$E+,N+}
  26. {$endif}
  27.  
  28. unit globals;
  29.  
  30.   interface
  31.  
  32.     uses
  33.       cobjects,objects,dos,strings
  34. {$ifdef linux}
  35.       ,linux
  36. {$endif}
  37.       ;
  38.  
  39. {$I version.inc}
  40.  
  41.     type
  42.        { later moved to system unit }
  43.        aword = longint;
  44. { for each processor define the best precision }
  45. {$ifdef i386}
  46.   {$ifdef ver_above0_9_8}
  47.        bestreal = extended;
  48.   {$else ver_above0_9_8}
  49.        bestreal = double;
  50.   {$endif ver_above0_9_8}
  51. {$endif i386}
  52. {$ifdef m68k}
  53.        bestreal = real;
  54. {$endif m68k}
  55.  
  56.  
  57.     const
  58.        { version string }
  59.        version_nr = '0';
  60.        release_nr = '99';
  61.        patch_nr   = '5';
  62. {$ifdef i386}
  63.        target = 'i386';
  64. {$endif}
  65. {$ifdef m68k}
  66.        target = 'M680x0';
  67. {$endif}
  68. {$ifdef alpha}
  69.        target = 'Alpha';
  70. {$endif}
  71.        version_string = version_nr+'.'+release_nr+'.'+patch_nr+' for '+target;
  72.  
  73. {$ifdef Splitheap}
  74.        testsplit : boolean = false;
  75. {$endif Splitheap}
  76.  
  77.        { max. significant length of strings }
  78.        maxidlen = 64;
  79.  
  80.     type
  81.        { I had to change the order for overloading
  82.          can this be a problem ? (PM)
  83.  
  84.          It will be no problem, if you change also the array to convert
  85.          tokens to strings (in PARSER.PAS) (FK)
  86.        }
  87.  
  88. {***IMPLIBGEN}
  89.        ttoken = (PLUS,MINUS,STAR,SLASH,EQUAL,GT,LT,GTE,LTE,_IS,_AS,_IN,
  90.                  SYMDIF,CARET,
  91.                  ASSIGNMENT,UNEQUAL,LECKKLAMMER,RECKKLAMMER,
  92.                  POINT,COMMA,LKLAMMER,RKLAMMER,COLON,SEMICOLON,
  93.                  KLAMMERAFFE,POINTPOINT,
  94.                  ID,REALNUMBER,_EOF,INTCONST,CSTRING,CCHAR,DOUBLEADDR,
  95.  
  96. {                _ABSOLUTE,}
  97.                  _AND,_ARRAY,_ASM,_BEGIN,
  98.                  _BREAK,_CASE,_CONST,_CONSTRUCTOR,_CONTINUE,
  99.                  _DESTRUCTOR,_DISPOSE,_DIV,_DO,_DOWNTO,_ELSE,_END,
  100.                  _EXIT,
  101. {                _EXPORT,}
  102.                  _EXTERNAL,_FAIL,_FALSE,
  103. {                _FAR,}
  104.                  _FILE,_FOR,
  105. {                _FORWARD,}
  106.                  _FUNCTION,_GOTO,_IF,_IMPLEMENTATION,
  107.                  _INHERITED,
  108. {                _INLINE,}
  109.                  _INTERFACE,
  110. {                _INTERRUPT,}
  111.                  _LABEL,_MOD,
  112. {                _NEAR,}
  113.                  _NEW,_NIL,_NOT,_OBJECT,
  114.                  _OF,_OTHERWISE,_OR,_PACKED,
  115.                  _PROCEDURE,_PROGRAM,
  116.                  _RECORD,_REPEAT,_SELF,
  117.                  _SET,_SHL,_SHR,_STRING,_THEN,_TO,
  118.                  _TRUE,_TYPE,_UNIT,_UNTIL,
  119.                  _USES,_VAR,_WHILE,_WITH,_XOR,
  120.                  { since Delphi 2 }
  121.                  _CLASS,_EXCEPT,_TRY,_ON,
  122. {                _ABSTRACT,}
  123.                  _LIBRARY,_INITIALIZATION,_FINALLY,_EXPORTS,_PROPERTY,
  124.                  _RAISE,
  125.                  { for operator overloading }
  126.                  _OPERATOR,
  127.  
  128.                  { C like operators }
  129.                  _PLUSASN,_MINUSASN,_ANDASN,_ORASN,_STARASN,_SLASHASN,
  130.                  _MODASN,_DIVASN,_NOTASN,_XORASN
  131.                  );
  132.  
  133.        tcswitch = (cs_none,
  134.          cs_check_overflow,cs_maxoptimieren,cs_uncertainopts,
  135.          cs_omitstackframe,cs_littlesize,cs_optimize,cs_debuginfo,
  136.          cs_compilesystem,cs_rangechecking,cs_support_goto,
  137.          cs_check_unit_name,cs_iocheck,cs_checkconsname,
  138.          cs_check_stack,cs_extsyntax,cs_typed_addresses,
  139.          cs_delphi2_compatible,cs_tp_compatible,cs_static_keyword,
  140.          cs_strict_var_strings,cs_fp_emulation,
  141. {$ifdef SUPPORT_MMX}
  142.          cs_mmx,cs_mmx_saturation,
  143. {$endif SUPPORT_MMX}
  144.          cs_profile,
  145.          cs_link_dynamic,cs_link_static,cs_no_linking,cs_unit_to_lib,
  146.          cs_shared_lib,cs_load_objpas_unit);
  147.  
  148.        tcswitches = set of tcswitch;
  149.  
  150.        pcswitches = ^tcswitches;
  151.  
  152.        stringid = string[maxidlen];
  153.  
  154.        pdouble = ^double;
  155.  
  156.        pbyte = ^byte;
  157.  
  158.        plongint = ^longint;
  159.  
  160. {$ifdef i386}
  161.        tprocessors = (i386,i486,pentium,pentiumpro,pentium2);
  162. {$endif}
  163. {$ifdef m68k}
  164.        tprocessors = (MC68000,MC68020);
  165. {$endif}
  166.  
  167.  
  168. {$ifdef i386}
  169.        tof = (of_none,of_o,of_obj,of_masm,of_att,of_nasm,of_win32);
  170. {$endif}
  171. {$ifdef m68k}
  172.        { the support will start with the following formats :
  173.          of_o = amiga/atari/mac native object format
  174.          of_gas = gas styled motorola assembler
  175.          of_mot = motorola styled assembler
  176.          of_mit = MIT syntax (old styled gas)
  177.        }
  178.        tof = (of_none,of_o,of_gas,of_mot,of_mit);
  179. {$endif}
  180.  
  181.        tcompilerstate = record
  182.           switches : tcswitches;
  183.           exprlevel : byte;
  184.        end;
  185.  
  186.        { this type will be sent from the compiler to the IDE to make up a }
  187.        { status window                                                    }
  188.        tcompilestatus = record
  189.               { filename }
  190.               currentsource : string;
  191.  
  192.               { current line number }
  193.               currentline : longint;
  194.  
  195.               { will implement a percentage bar         }
  196.  
  197.               { the number of lines which are compiled  }
  198.               totalcompiledlines : longint;
  199.  
  200.               { Note:                                   }
  201.               { it's possible that totallines is zero,  }
  202.               { this means the compiler didn't know the }
  203.               { total lines                             }
  204.               totallines : longint;
  205.        end;
  206.  
  207.        { such a procedure is called from the compiler, }
  208.        { to put some informations to the ide etc.      }
  209.        { if the function returns true, the compiler    }
  210.        { stops                                         }
  211.        tcompilestatusproc = function(const status : tcompilestatus) : boolean;
  212.  
  213. {$ifdef i386}
  214.        ti386asmmode = (I386_ATT,I386_INTEL,I386_DIRECT);
  215.  
  216.     const
  217.        { the current mode which is in assembler blocks assumed }
  218.        aktasmmode : ti386asmmode = I386_DIRECT;
  219. {$endif}
  220.  
  221.     var
  222.        compilestatusproc : tcompilestatusproc;
  223.  
  224.        inputdir       : dirstr;
  225.        inputfile      : namestr;
  226.        inputextension : extstr;
  227.        { some flags for global compiler switches }
  228.        use_pipe,
  229.        do_build,do_make,writeasmfile,externasm,externlink : boolean;
  230.        assem_need_external_list,not_unit_proc : boolean;
  231.        { path for searching units, different paths can be seperated by ; }
  232.        exepath            : dirstr;  { Path to ppc }
  233.        unitsearchpath,
  234.        objectsearchpath,
  235.        includesearchpath,
  236.        librarysearchpath  : string;
  237.  
  238.        initswitches  : tcswitches;
  239.        { alignement of records }
  240.        initpackrecords : word;
  241.  
  242.        { current state state }
  243.        aktswitches    : Tcswitches;
  244.        aktpackrecords : word;
  245.        { this list contains the defines      }
  246.        { from the command line, this defines }
  247.        commandlinedefines : tlinkedlist;
  248.  
  249.        abslines : longint;         { number of lines which are compiled }
  250.        in_args : boolean;          { arguments must be checked especially }
  251.        parsing_para_level : longint; { parameter level, used to convert
  252.                                      proc calls to proc loads in firstcalln }
  253.        Must_be_valid : boolean;    { should the variable already have a value }
  254.  
  255. {$ifdef TP}
  256.        use_big      : boolean;
  257. {$ifndef dpmi}
  258.        symbolstream : temsstream;  { stream which is used to store some     }
  259.                                    { informtions to u